const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let d, n;
let initArr = []
rl.on("line", (line)=>{
    if(d === undefined) {
        d = Number(line.trim())
    } else if(n === undefined) {
        n = Number(line.trim())
    } else {
        initArr.push(line.trim().split(" ").map(Number))
        if(initArr.length === n) {
            console.log(getResult(d, n, initArr))

            // clear
            d = n = undefined;
            initArr.length = 0
        }
    }

})

function getResult(d, n, initArr) {
    let time = d/ 100;
    if(d <= 1000) return time;
    let map = new Map();

    // 开始使用倒序 + dfs, 以终点为根,进行dfs
    let waitTime = dfs(1000, d, map) // 电量 + 目的地距离
    if(waitTime === Infinity) return -1

    return time + waitTime
}

function dfs(power, distance, map) {
    if(distance <= power) return 0 // 不需要充电
    if(map.has(distance)) return map.get(distance) // 缓存

    let diff = distance - power
    let time = Infinity;
    for (const arr of initArr) {
        const [d, t] = arr

        // 这些站点可以充电
        if(d >= diff && d < distance) {
            let currentTime = dfs(1000, d, map)
            if(currentTime === Infinity) continue;
            time = Math.min(time, currentTime + t + 1)
        }
    }
    map.set(distance, time)
    return time
}